package com.hxzy.config;

import com.hxzy.interceptor.FirstTestInterceptor;
import com.hxzy.interceptor.LoginCheckInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author wzm
 * @create 2024-03-11 14:44
 * project_name:JavaWeb2401
 * @Description
 */
//配置web相关组件的类
@Configuration
public class WebConfig implements WebMvcConfigurer {

    //注册自定义拦截对象到配置中

    //注入拦截器对象
    @Autowired
    private LoginCheckInterceptor loginCheckInterceptor;
//    FirstTestInterceptor firstTestInterceptor;


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册拦截器对象并添加拦截的路径
       registry.addInterceptor(loginCheckInterceptor).addPathPatterns("/**")// /**表示拦截所有路径
               .excludePathPatterns("/login");//设置不拦截的路径为login
    }
}


